using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using MyFrame.Pool;
using UnityEngine;

public class BloodStainController : MonoBehaviour
{
    public float lifeTime;  // 物体存活时间
    Vector2 currentLocalScale;//初始缩放
    Color currentColor;//初始缩放
    SpriteRenderer sprite;  // 精灵渲染器

    private void Awake()
    {
        sprite = GetComponent<SpriteRenderer>();
        currentLocalScale = transform.localScale;
        currentColor = sprite.color;
    }

    void OnEnable()
    {
        transform.localScale = Vector3.zero;
        sprite.color = currentColor;
        //先变大
        transform.DOScale(currentLocalScale, lifeTime / 3).From(Vector3.zero).OnComplete(() =>
        {
            //再渐隐
            sprite.DOFade(0f, lifeTime / 3 * 2).From(1f).OnComplete(() =>
            {
                PoolMgr.Instance.Release(gameObject);
            });
        });
    }
}
